<%@page import="com.license.logic.profile.MedicalProfile"%>
<%@page import="com.license.logic.profile.PersonalProfile"%>
<%@page import="com.license.logic.profile.EmployeeProfile"%>
<%@page import="com.license.logic.alimentation.Food"%>
<%@page import="com.license.logic.preference.Activity"%>
<%@page import="com.license.servlets.EmployeeServlet"%>
<%@page import="com.license.logic.preference.Preferences" %>
<%@page import="java.util.List"%>
<%@page import="java.util.Map"%>
<%@include file="AdminBasePage.jsp"%>
<f:view>
	<html>

<div class="span9">
	<h1 class="page-title">Edit employee</h1>
	<% EmployeeServlet employeeServlet = new EmployeeServlet();
	   Map<String,List<String>> preferences = employeeServlet.getEmployeePreferences(request, response);
	   EmployeeProfile employeeProfile = (EmployeeProfile) session.getAttribute("employeeProfileToEdit");
	   %>
	<div class="well">
		<div id="myTabContent" class="tab-content">
			<div class="tab-pane active in" id="home" style="height : 400px;">
				<form id="tab" style="height : 400px;witdh: 200px;" action="../EmployeeServlet?operation=updateEmployee" method="post">		
						<%
							PersonalProfile persProfile = employeeProfile.getPersonalProfile(); 
							MedicalProfile medicalProfile = employeeProfile.getMedicalProfile();
						%>
						
						<input hidden="true" id="operation" name="operation" />
						<label>Name</label> 
						<input type="text" id="name" name="name"  class="input-xlarge" value="<%=persProfile.getName() %>" />
						
						<label id="labelweight">Weight</label>
						<input type="text" id="weight" name="weight" class="input-xlarge" value="<%=persProfile.getWeight() %>"/>
						<label id="labelheight">Height</label> 
						<input type="text" id="height" name="height"  class="input-xlarge" value="<%=persProfile.getHeight() %>"/>
						<div>
							<label id="labelsex">Sex:</label>
							<select id="sex" name="sex" onchange="#">  
									<option value="Male" selected="<%="m".equals(persProfile.getSex()) %>">Male</option>
									<option value="Female" selected="<%="f".equals(persProfile.getSex()) %>">Female</option>
								</select> 
						</div>
        			<label id="labelsmoker">Smoker</label>
					<select id="smoker" name="smoker" onchange="#">  
								<%if (medicalProfile.getMedicalHistory().isSmoker()){ %>
								<option value="true" selected="true">true</option>
								<option value="false" >false</option>
								<%} else { %>
								<option value="true" >true</option>
								<option value="false" selected="true">false</option>
								
								<%} %>
					</select> 
					<label id="labeldiabetic">Diabetic</label>
					<select id="diabetic" name="diabetic" onchange="#">  
								<%if (medicalProfile.getMedicalHistory().isDiabets()){ %>
								<option value="true" selected="true">true</option>
								<option value="false" >false</option>
								<%} else { %>
								<option value="true" >true</option>
								<option value="false" selected="true">false</option>
								
								<%} %>
					</select> 
					
					<label id="labelsbp">SBP</label>
					<input type="text" id="sbp" name="sbp"  class="input-xlarge" value="<%=medicalProfile.getMedicalHistory().getSbp() %>"/>
					
					<label id="labelageEmployee">Age</label>
						<input type="text" id="ageEmployee" name="ageEmployee" class="input-xlarge" value="<%=persProfile.getAge() %>"/>
					
					<label id="labelfamilyhistory">Family History</label>
						<select id="familyHistory" name="familyHistory" onchange="#">  
								<%if (medicalProfile.getGeneticalHistory().isFamilyCardioHistory()){ %>
								<option value="true" selected="true">true</option>
								<option value="false" >false</option>
								<%} else { %>
								<option value="true" >true</option>
								<option value="false" selected="true">false</option>
								
								<%} %>
					</select> 
					
					<label id="labelActivityCalory">Activity Calory</label>
						<input type="text" id="activityCalory" name="activityCalory" class="input-xlarge" value="<%=medicalProfile.getMedicalHistory().getActivityKalory() %>"/>
					
					
					<label id="labelNutritionCalory">Nutrition Calory</label>
						<input type="text" id="nutritionCalory" name="nutritionCalory" class="input-xlarge" value="<%=medicalProfile.getMedicalHistory().getNutritionKalory() %>" />
					
					
					<label id="meal_preferences" style="font-size: 16px;">Meal Preference</label>
					<div id="meal_preferences">
							   <%for(String preference : preferences.get("meal")) {
								   boolean found = false;
							   		for (Food food : persProfile.getPreference().getNutritions()){
							   			if (food.getName().equals(preference)){
							   				found = true;
							   			}
							   		}
							   		if (found){
							   %>	
										<input type="checkbox" name="food_<%=preference%>" class="styled" value="<%=preference%>" checked="checked" /> <%=preference%> </br></br>
									<% } else { %>
										<input type="checkbox" name="food_<%=preference%>" class="styled" value="<%=preference%>" /> <%=preference%> </br></br>
									<%} %>								
								<%}%>									
					</div>
					<label id="soup_preferences" style="font-size: 16px;">Soup Preference</label>
					<div id="soup_preferences">
							   <%for(String preference : preferences.get("soup")) {
								   boolean found = false;
						   		for (Food food : persProfile.getPreference().getNutritions()){
						   			if (food.getName().equals(preference)){
						   				found = true;
						   			}
						   		}
						   		if (found){
						   %>	
									<input type="checkbox" name="food_<%=preference%>" class="styled" value="<%=preference%>" checked="checked" /> <%=preference%> </br></br>
								<% } else { %>
									<input type="checkbox" name="food_<%=preference%>" class="styled" value="<%=preference%>" /> <%=preference%> </br></br>
								<%} %>								
							<%}%>										
					</div>
					<label id="fruit_preferences" style="font-size: 16px;">Fruit Preference</label>
					<div id="fruit_preferences">
							   <%for(String preference : preferences.get("fruit")) {
								   boolean found = false;
							   		for (Food food : persProfile.getPreference().getNutritions()){
							   			if (food.getName().equals(preference)){
							   				found = true;
							   			}
							   		}
							   		if (found){
							   %>	
										<input type="checkbox" name="food_<%=preference%>" class="styled" value="<%=preference%>" checked="checked" /> <%=preference%> </br></br>
									<% } else { %>
										<input type="checkbox" name="food_<%=preference%>" class="styled" value="<%=preference%>" /> <%=preference%> </br></br>
									<%} %>								
								<%}%>									
					</div>
					<label id="graminea_preferences" style="font-size: 16px;">Graminea Preference</label>
					<div id="graminea_preferences">
							   <%for(String preference : preferences.get("graminea")) {
							    boolean found = false;
							   		for (Food food : persProfile.getPreference().getNutritions()){
							   			if (food.getName().equals(preference)){
							   				found = true;
							   			}
							   		}
							   		if (found){
							   %>	
										<input type="checkbox" name="food_<%=preference%>" class="styled" value="<%=preference%>" checked="checked" /> <%=preference%> </br></br>
									<% } else { %>
										<input type="checkbox" name="food_<%=preference%>" class="styled" value="<%=preference%>" /> <%=preference%> </br></br>
									<%} %>								
								<%}%>										
					</div>
					<label id="vegetable_preferences" style="font-size: 16px;">Vegetable Preference</label>
					<div id="vegetable_preferences">
							   <%for(String preference : preferences.get("vegetable")) {
							    boolean found = false;
							   		for (Food food : persProfile.getPreference().getNutritions()){
							   			if (food.getName().equals(preference)){
							   				found = true;
							   			}
							   		}
							   		if (found){
							   %>	
										<input type="checkbox" name="food_<%=preference%>" class="styled" value="<%=preference%>" checked="checked" /> <%=preference%> </br></br>
									<% } else { %>
										<input type="checkbox" name="food_<%=preference%>" class="styled" value="<%=preference%>" /> <%=preference%> </br></br>
									<%} %>								
								<%}%>									
					</div>
					<label id="activity_preferences" style="font-size: 16px;">Activity Preference</label>
					<div id="activity_preferencess">
							   <%for(String preference : preferences.get("PhisicalActivity")) {
								   boolean found = false;
							   		for (Activity activity : persProfile.getPreference().getActivities()){
							   			if (activity.getName().equals(preference)){
							   				found = true;
							   			}
							   		}
							   		if (found){
							   %>	
							   <input type="checkbox" name="activity_<%=preference%>" class="styled" value="<%=preference%>" checked="checked"/> <%=preference%> </br></br>
									<% } else { %>
										<input type="checkbox" name="activity_<%=preference%>" class="styled" value="<%=preference%>" /> <%=preference%> </br></br>
									<%} %>								
								<%}%>	
									
					</div>
					<input class="btn btn-primary" id="updateEmployee_e" style="position: relative;top: -2202px;" type="submit" value="Update"/>
				</form>
			</div>
		</div>

	</div>

</div>
</div>
<footer>
	<hr>
	<!-- Purchase a site license to remove this link from the footer: http://www.portnine.com/bootstrap-themes -->
	<p class="pull-right">
		Procadio <a href="#" target="_blank">best lifestile recomandation
			software</a>
	</p>
	<p>
		&copy; 2013 <a href="#">Cozac Adrian & Mesaros Ionut</a>
	</p>
</footer>
</body>
</html>
</f:view>